#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int > vec;
typedef pair < int , int > pii;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 2e3 + 10;
const int M = N * 3;
const int mod = 1e9 + 7;

int upd(int x) { return x + (x >> 31 & mod); }

int f[N][M], g[N][M], fac[M], ifac[M], n, m, ans = 1, ept, tot; // f : up and down, g : left and right
char s[3][N];

ll qp(ll x, int t) { ll res = 1; for(; t; t >>= 1, x = x * x % mod) if(t & 1) res = res * x % mod; return res; }

void init(int l) {
	fac[0] = 1; rep(i, 1, l) fac[i] = 1ll * fac[i - 1] * i % mod; ifac[l] = qp(fac[l], mod - 2);
	per(i, l - 1, 0) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % mod; 
}

inline ll A(int x, int y) { return x < y ? 0 : 1ll * fac[x] * ifac[x - y] % mod; }
inline ll C(int x, int y) { return x < y || x < 0 || y < 0 ? 0 : 1ll * fac[x] * ifac[x - y] % mod * ifac[y] % mod; }

signed main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    n = in; rep(i, 0, 2) scanf("%s", s[i] + 1); init(n * 3);
	rep(i, 0, 2) {
		if(i == 1) continue;
		rep(j, 2, n) if(s[i][j - 1] == 'x' && s[i][j] == 'x') return puts("0"), 0;
		if(s[i][1] == 'x' || s[i][n] == 'x') return puts("0"), 0;
	}
	if(s[1][1] == 'x') { f[1][1] = 1, ept = 1; rep(j, 1, n * 3) f[1][j] = upd(f[1][j - 1] + f[1][j] - mod); }
	rep(i, 2, n) {
		tot = (s[0][i] == 'x') + (s[2][i] == 'x');
		if(s[1][i] == 'x') {
			if(s[1][i - 1] == 'x') {
				ept += tot + 1;
				rep(j, 1, ept) {
					f[i][j] = upd(f[i - 1][ept] * A(j - 1, tot) % mod - mod); // all up and down
					f[i][j] = upd(f[i][j] + upd(g[i - 1][ept] - g[i - 1][max(j - tot - 1, 0)]) * A(j - 1, tot) % mod - mod);
					// i up and down, i - 1 left and right
					rep(k, 1, tot) {
						g[i][j + k] = upd(g[i][j + k] + f[i - 1][j] * C(j + k - 1, k - 1) % mod * fac[tot] % mod * C(ept - j - k, tot - k + 1) % mod - mod);
					} // i left and right, i - 1 up and down
				}
			} else {
				f[i][ept = tot + 1] = fac[tot];
				if(tot >= 1) g[i][1] = fac[tot];
				if(tot >= 2) g[i][2] = fac[tot];
			}
			rep(j, 1, n * 3) f[i][j] = upd(f[i][j - 1] + f[i][j] - mod), g[i][j] = upd(g[i][j - 1] + g[i][j] - mod);
		} else {
			if(s[1][i - 1] == 'x') ans = 1ll * ans * C(m += ept, ept) % mod * upd(f[i - 1][ept] + g[i - 1][ept] - mod) % mod;
			ans = 1ll * ans * A(m += tot, tot) % mod;
		}
	}
	if(s[1][n] == 'x') ans = 1ll * ans * f[n][ept] % mod * C(m + ept, ept) % mod;
	cout << ans << endl; return 0;	
}
